<?php

class MayijieAction extends Action{
	public function preMethod()
	{
	}

	public function login(){
		$this->name="管理中心";
		$this->display();
	}

	public function check(){
		$Admin=M('Admin');
		$map['uname']=$this->_post('opadmin');
		$pwd=$this->_post('pwd');
		$map['password']=md5($pwd);
		$result=AdminModel::getAdminInfo($map);
		if($result){
			session('admin_name',$result['uname']);
			session('admin_role',AdminModel::getAdminRole($result['id']));
			session('admin_perm',$result['perm_key']);
			AdminModel::setLoginTime($result['id']);
			$this->success("登陆成功！",'__GROUP__/Index');
		}else{
			$this->error("账号或密码错误");
		}
	}

	public function check_admin(){
		$admin=session('admin_name');
		if(!isset($admin)){
			$this->redirect('Admin/Mayijie/login');
		}
	}

	public function login_out()
	{
		session('admin_name',null);
		session('admin_role',null);
		session('admin_perm',null);
		echo "<script>window.parent.location.reload();</script>";
		//$this->success("退出成功！",'__GROUP__/Index');
	}

}
?>